﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Tomahawk.Runtime.Timeline
{
    public class IntTrack : BaseTrack
    {
        [XmlElement("Value")]
        public string value = "";

        private Curve curveValue = null;

        public IntTrack() { }

        public IntTrack(string name) : base(name) { }

        protected override bool OnLoad(GraphicsDevice graphics, ContentManager contentManager)
        {
            curveValue = LoadCurve(contentManager, value);
            return base.OnLoad(graphics, contentManager);
        }

        public override void SortKeys() { }

        public override bool Update(float time)
        {
            if (curveValue == null)
            {
                return false;
            }

            int value = (int)Math.Round(curveValue.Evaluate(time));
            return SetPropertyValue<int>(value);

        }
    }
}
